package com.hrt.test.common;

public class MsgConsumer extends Thread {

    private String name;
    private String tag;

    public MsgConsumer(String name, String tag) {
        this.name = name;
        this.tag = tag;
    }

    @Override
    public void run() {
        try {
            MsgQueueManager.getInstance().consume(name, new IMsgListener() {

                int counter = 1;

                @Override
                public void onReceive(Object msg) {
                    System.out.println(tag + "消费：" + msg + ",消息数量：" + counter);
                    counter++;
                }
            });
        } catch (QueueHasBeenListenedException | NullQueueListenerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}
